const url = require('url')

// const urlString = '//www.baidu.com:443/app/index.html?id=2&city=北京#flag=123'

const urlObj = {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'www.baidu.com:443',
  port: '443',
  hostname: 'www.baidu.com',
  hash: '#flag=123',
  search: '?id=2&city=北京',
  query: { id: '2', city: '北京' },
  pathname: '/app/index.html',
  path: '/app/index.html?id=2&city=北京',
  href: 'https://www.baidu.com:443/app/index.html?id=2&city=北京#flag=123'
}

// console.log(url.parse(urlString, true, true))
// console.log(url.format(urlObj))

console.log(url.resolve('https://www.baidu.com/a/b/c', '../d'))

